package www.sharetime.weshare.adapter;

import android.content.Context;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import www.sharetime.weshare.fragment.GoodsFragment;
import www.sharetime.weshare.fragment.UserShareFragment;

/**
 * File Description  : 首页，分享和商品的页面适配器
 *
 * @author : zhanggeng
 * @email : zhanggengdyx@gmail.com
 * @date : 2017/9/13 20:41
 * @version     : v1.0
 * **************修订历史*************
 */

public class HomeFragmentPagerAdapter extends FragmentPagerAdapter {

    final int PAGE_COUNT = 2;
    private String tabTitles[] = new String[] { "分享", "商品"};
    private Context context;

    public HomeFragmentPagerAdapter(FragmentManager fm, Context context) {
        super(fm);
        this.context = context;
    }


    @Override
    public Fragment getItem(int position) {

        Fragment fragment = null;

        switch (position){
            case  0:
                fragment = new UserShareFragment();
                break;
            case 1:
                fragment = new GoodsFragment();
                break;
        }
        return fragment;
    }

    @Override
    public CharSequence getPageTitle(int position) {
        return tabTitles[position];
    }

    @Override
    public int getCount() {
        return 2;
    }
}
